<template>
  <div class="page-wrap">
    <PiForm ref="form" labelWidth="200px" :formList="formList" :model="model"></PiForm>
  </div>
</template>

<script setup name="piFormPart">
const layoutObj = [
  {
    groupName: '属性',
    items: [
      {
        label: '名称',
        name: 'name',
        row: 1,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: true,
        single: true,
        readOnly: false,
        filedType: 'INPUT',
        displayValue: '',
      },
      {
        label: '标题',
        name: 'title',
        row: 2,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: false,
        single: true,
        readOnly: false,
        filedType: 'INPUT',
        displayValue: '',
      },
      {
        label: '说明',
        name: 'description',
        row: 3,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: false,
        single: true,
        readOnly: false,
        filedType: 'INPUT',
        displayValue: '',
      },
      {
        label: '位置',
        name: 'folder.id',
        row: 4,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: false,
        single: true,
        readOnly: false,
        filedType: 'REMOTESELECT',
        displayValue: '',
      },
      {
        label: 'lifeCycle.id',
        name: 'lifeCycle.id',
        row: 5,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: false,
        single: true,
        readOnly: false,
        filedType: 'INPUT',
        displayValue: '',
      },
      {
        label: 'teamTemplate.id',
        name: 'teamTemplate.id',
        row: 6,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: false,
        single: true,
        readOnly: false,
        filedType: 'INPUT',
        displayValue: '',
      },
    ],
    objType: 'wt.doc.WTDocument',
  },
  {
    groupName: '业务',
    items: [
      {
        label: '测试属性',
        name: 'testIBA',
        row: 0,
        col: 0,
        value: '',
        dataType: 'java.lang.String',
        required: false,
        single: true,
        readOnly: false,
        filedType: 'INPUT',
        displayValue: '',
      },
    ],
    objType: 'wt.doc.WTDocument',
  },
];
let formList = reactive([]);
let submitData = reactive({});
const getFormList = () => {
  formList = [];
  submitData = {};
  layoutObj.forEach((item) => {
    const rows = Array.from(new Set(item.items.map((el) => el.row)));
    const list = [];
    rows.forEach((row) => {
      const arr = item.items.filter((el) => el.row === row);
      list.push(arr);
    });
    formList.push({
      groupName: item.groupName,
      list,
    });
    item.items.forEach((el) => {
      submitData[el.name] = item.vlue;
    });
  });
};
onBeforeMount(() => {
  getFormList();
});
</script>

<style></style>
